const http = require('http');
const fs = require('fs');
const path = require('path');
//npm install mime
const mime = require('mime');

http.createServer(function (req,res){ const Dirname = path.join(__dirname,'public');
    const Filename = path.join(Dirname,req.url);
    fs.readFile(Filename,function (err, data) {
        if (err) {
            res.end('Hello NodeJS !!!');
        }else {
            res.setHeader('Content-Type',mime.getType(Filename));
            res.end(data);
        }
    })
}).listen(8008,function () {
    console.log('http://localhost:8008');
});